/* 
 * Advanced Foundation Classes
 * Copyright (C) 2000/2004  Fabio Rotondo - Andrea Galimberti
 *  
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *  
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *  
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */
#include "../easygui.h"
#include "../widgets.h"

int btn_add_window_click ( DynamicClass * dc, EasyGUIContext * context )
{
	EasyGUIContext * c;

	c = afc_easygui_add_context ( context->egui, NULL );
	afc_easygui_context_set_gui_from_file ( c, "gui_multiwin_ext.txt" );
	afc_easygui_context_show ( c );

	return ( AFC_ERR_NO_ERROR );
}

int entry_activate ( DynamicClass * dc, EasyGUIContext * context, const char * text )
{
	EasyGUIContext * main_context;

	main_context = afc_easygui_get_context ( context->egui, AFC_EASYGUI_CONTEXT_MAIN );
	afc_easygui_widget_execute ( main_context, "lbl_text", "set_text", text, AFC_EASYGUI_ARG_END );

	return ( AFC_ERR_NO_ERROR );
}

int main ( int argc, char * argv[] )
{
	AFC * afc = afc_new (); 
	EasyGUI * easygui;
	EasyGUIContext * context;
	int afc_res = 0;

	afc_track_mallocs ( afc );

	afc_set_tags ( afc, AFC_TAG_LOG_LEVEL, 	AFC_LOG_WARNING, 
			    AFC_TAG_SHOW_FREES, FALSE,
			    AFC_TAG_SHOW_MALLOCS, FALSE,
			    AFC_TAG_END );

	easygui = afc_easygui_new ( afc );

	if ( easygui == NULL ) 
	{
	  fprintf ( stderr, "Init of class EasyGUI failed.\n" );
	  return ( 1 );
	}

	afc_easygui_init ( easygui );
	context = afc_easygui_add_context ( easygui, AFC_EASYGUI_CONTEXT_MAIN );

	afc_easygui_context_set_gui_from_file ( context, "gui_multiwin_base.txt" );

	if ( ( afc_res = afc_easygui_context_show ( context ) ) != AFC_ERR_NO_ERROR ) {
		fprintf ( stderr, "res: %x\n", afc_res );
	}
	else afc_easygui_main ( easygui );

	afc_easygui_delete ( easygui );

	afc_delete ( afc );

	return ( 0 ); 
}
